<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的收藏</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2 id="doubleClick">我的收藏</h2>
    </header>
</div>
<div class="mescroll" id="mescroll" style="padding-top: 1.5rem">
    <section class="html_section pr30 pl30 ">
        <ul class="userType_list">
            <li tapmode class="on">新闻</li>
            <li tapmode>帖子</li>
        </ul>

        <div class="page_box on" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="index-news collection-list">
                <ul>

                </ul>
                <div class="nodata"></div>
            </div>
        </div>
        <div class="page_box" data-page="1" data-ifpage='true' data-ready='false'>
            <div class="index-news user-dynamic">
                <ul id="tiezi_list">

                </ul>
                <div class="nodata"></div>
            </div>
        </div>
    </section>
</div>

</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">
    var type = 1;
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading()
        keybackListener()
        //上拉加载
        pullUpLoading(function () {
            var ifpage = $(".page.on").data("ifpage");
            if (ifpage == true) {
                var page = Number($(".page.on").data("page"));
                page++
                $(".page.on").data("page", page);
                ready();
            }
        });
        //下拉刷新
        /*dropDownRefresh(function () {
            $(".page_box.on").data('page', 1);
            $(".page_box.on").data('ifpage', true);
            ready();
        })*/
        var isOne = true;
        api.addEventListener({
            name: 'viewappear'
        }, function (ret, err) {
            if (isOne) {
                isOne = false;
                ready();
            }
        });
    }
    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        }
    });
    /*下拉刷新的回调 */
    function downCallback() {
        $(".page_box.on").data('page', 1);
        $(".page_box.on").data('ifpage', true);
        ready();

        //mescroll.endErr();
    }


    function ready() {
        var page = $(".page_box.on").data("page");
        getAjax(Interface.get_collection, {token: $api.getStorage('token'), page: page, type: type}, function (res) {
            var list = res.data.list;
            var html = '';
            if(isDefine(list)){
                $.each(list, function (i, item) {
                    if (type == 1) {
                        var toUp = '';
                        var hotHtml = '';
                        if (isDefine(item)) {
                            var data = item.data;
                            if (data.recommend == 1) {
                                toUp = '<span class="bt-pd toUp">置顶</span>';
                            }
                            if (isDefine(data.news_label_name)) {
                                if (data.news_label_name.length >= 2) {
                                    hotHtml = '<div class="detail-bottom">' +
                                        '              <div class="bottom-tips">' + toUp +
                                        '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + data.news_label_name[0].id + '})\'>#' + data.news_label_name[0].title + '#</span>' +
                                        '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + data.news_label_name[1].id + '})\'>#' + data.news_label_name[1].title + '#</span>' +
                                        '                  <span class="bt-pd time">' + data.date + '</span>' +
                                        '              </div>' +
                                        '              <div class="bottom-hot">' + data.hot_number + '</div>' +
                                        '          </div>';
                                } else if (data.news_label_name.length == 1) {
                                    hotHtml = '<div class="detail-bottom">' +
                                        '              <div class="bottom-tips">' + toUp +
                                        '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + data.news_label_name[0].id + '})\'>#' + data.news_label_name[0].title + '#</span>' +
                                        '                  <span class="bt-pd time">' + data.date + '</span>' +
                                        '              </div>' +
                                        '              <div class="bottom-hot">' + data.hot_number + '</div>' +
                                        '          </div>';
                                }

                            } else {
                                hotHtml = '<div class="detail-bottom">' +
                                    '              <div class="bottom-tips">' + toUp +
                                    '                  <span class="bt-pd time">' + data.date + '</span>' +
                                    '              </div>' +
                                    '              <div class="bottom-hot">' + data.hot_number + '</div>' +
                                    '          </div>';
                            }
                        }

                        var param;
                        var url;
                        if(isDefine(data.url)){
                            param = {"url": data.url,"news_id": data.id};
                            url = '../index/banner_detail';
                        }else {
                            param = {"news_id": data.id};
                            url = "../index/news_detail";
                        }

                        //标题，文字，图片
                        var titleHtml = '';
                        if (isDefine(data.void_path)) {

                            //视频新闻
                            titleHtml = '<div class="video-detail">' +
                                '             <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ')\'>' + data.title + '</h6>' +
                                '             <div class="video-box bg-cover" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ')\' style="background-image: url(' + ajaxUrl + data.void_icon_path + ')";>' +
                                '                 <p class="single-ellipsis"></p>' +
                                '                 <span class="icon-play"></span>' +
                                '                 <span class="time"></span>' +
                                '              </div>' + hotHtml +
                                '         </div>';
                            if(item.leixing == 6){
                                //视频新闻
                                var param = {"war_id": data.id}
                                titleHtml = '<div class="video-detail" >' +
                                    '             <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' + data.title + '</h6>' +
                                    '             <div class="video-box bg-cover" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\' style="background-image: url(' + ajaxUrl + data.void_icon_path + ')";>' +
                                    '                 <p class="single-ellipsis"></p>' +
                                    '                 <span class="icon-play"></span>' +
                                    '                 <span class="time"></span>' +
                                    '              </div>' + hotHtml +
                                    '         </div>';
                            }
                        } else {
                            //三张图片新闻
                            if(isDefine(data.icon_path) && item.leixing != 6){
                                if (data.icon_path.length >= 3) {
                                    titleHtml = '<div class="video-detail">' +
                                        '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + data.title + '</h6>' +
                                        '            <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                        '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[0] + ');"></div>' +
                                        '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[1] + ');"></div>' +
                                        '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[2] + ');"></div>' +
                                        '            </div>' + hotHtml +
                                        '        </div>';
                                } else if (data.icon_path.length == 2) {
                                    //两张图片新闻
                                    titleHtml = '<div class="video-detail">' +
                                        '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + data.title + '</h6>' +
                                        '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                        '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[0] + ');"></div>' +
                                        '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[1] + ');"></div>' +
                                        '            </div>' + hotHtml +
                                        '        </div>';
                                    //赛况
                                    if(item.leixing == 6){
                                        //两张图片新闻
                                        var param = {"war_id": data.id}
                                        titleHtml = '<div class="video-detail">' +
                                            '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' + data.title + '</h6>' +
                                            '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' +
                                            '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[0] + ');"></div>' +
                                            '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[1] + ');"></div>' +
                                            '            </div>' + hotHtml +
                                            '        </div>';
                                    }
                                } else if (data.icon_path.length == 1) {

                                    if (data.recommend == 1) {
                                        toUp = '<span class="bt-pd toUp">置顶</span>';
                                    }
                                    if (isDefine(data.news_label_name)) {
                                        if (data.news_label_name.length >= 1) {
                                            hotHtml = '<div class="detail-bottom">' +
                                                '              <div class="bottom-tips">' + toUp +
                                                '                  <span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + data.news_label_name[0].id + '})\'>#' + data.news_label_name[0].title + '#</span>' +
                                                '                  <span class="bt-pd time">' + data.date + '</span>' +
                                                '              </div>' +
                                                '              <div class="bottom-hot">' + data.hot_number + '</div>' +
                                                '          </div>';
                                        }

                                    }
                                    //单张图片新闻
                                    titleHtml = '<div class="single-news">' +
                                        '             <div class="detail-img-list" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' +
                                        '                 <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[0] + ');"></div>' +
                                        '             </div>' +
                                        '             <div class="video-detail">' +
                                        '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + data.title + '</h6>' + hotHtml +
                                        /*  '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("../index/news_detail",' + jsonChange(param) + ')\'>' + data.brief + '</p>' + hotHtml +*/
                                        '             </div>' +
                                        '         </div>';
                                    //赛况
                                    if(item.leixing == 6){
                                        //两张图片新闻
                                        var param = {"war_id": data.id}
                                        titleHtml = '<div class="single-news">' +
                                            '             <div class="detail-img-list" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' +
                                            '                 <div class="img bg-cover" style="background-image: url(' + ajaxUrl + data.icon_path[0] + ');"></div>' +
                                            '             </div>' +
                                            '             <div class="video-detail">' +
                                            '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'>' + data.title + '</h6>' + hotHtml +
                                            /* '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("../match/match_detail",' + jsonChange(param) + ')\'></p>' + hotHtml +*/
                                            '             </div>' +
                                            '         </div>';
                                    }
                                }
                            }
                        }
                        // console.log('-------------------------');
                        // console.log(titleHtml);
                        html += '<li>' + titleHtml + '</li>'
                    } else {
                        html += tiesList(item);
                    }
                })
                if (page == 1){
                    $(".page_box.on ul").html(html);
                } else{
                    $(".page_box.on ul").append(html);
                }
                if (list.length < res.data.sumpage) {
                    $(".page_box.on").data('ifpage', false);
                    $(".page_box.on .nodata").show();
                } else {
                    $(".page_box.on .nodata").hide();
                }
                if (list.length == 0) {
                    if (page == 1) {
                        $(".page_box.on .nodata").hide();
                        $(".page_box.on ul").html(noData);
                    }
                }
            } else {
                $(".page_box.on ul").html(noData);
                $(".page_box.on .nodata").hide();
            }
            pop.close();
            mescroll.endErr()
        }, function (res, err) {
            pop.close();
            $(".page_box.on ul").html(noData);
            mescroll.endErr()
        })
    }

    $(".userType_list li").click(function () {
        $(".userType_list li").removeClass("on");
        $(this).addClass("on");
        type = $(this).index() + 1;
        var ifr = $(".page_box.on").data('ready');
        if (ifr == false) {
            ready();
        }
    })

    //取消关注
    function qxLike(id) {
        $("#li_" + id).addClass("del");
        setTimeout(function () {
            $("#li_" + id).remove();
        }, 1300);
    }

    function follow(e) {
        if ($(e).hasClass("on")) {
            $(e).removeClass("on");
        } else {
            $(e).addClass("on");
        }
    }

</script>
